var t = getApp();

Page({
    data: {
        wechat_openid: t.globalData.wechat_openid,
        userInfo: {},
        rps:1,
        wx_code:'/images/blank.jpg',
        imgPath:'',
        tab_choose_index: 0,
        //http://p15eu3hv7.bkt.clouddn.com/wuxingxiaotupian.png
        simple: {
            image: ""
        },
        tipstate: !1,
        simpleBtn: !0,
        funny: {},
        noticeCover: !1,
        imgUrls1: [ "http://p15eu3hv7.bkt.clouddn.com/guanggao_2.png", "http://p15eu3hv7.bkt.clouddn.com/guanggao_1.png" ],
        textCurrent: 0,
        imgUrls2: [ {
            url: "http://p15eu3hv7.bkt.clouddn.com/fa1.png",
            cont: {
                title1: "简单，服务体验至上",
                title2: "第一次，为命理占卜定义标准0",
                itemList: [ [ "为服务定义标准", "明确的服务介绍/清晰的服务范围", "完善的服务流程/不满意即时退款", "合理的定价策略/对敌仅需19元起", "灵活的匹配机制/不纠结谁来占测", "···" ] ]
            }
        }, {
            url: "http://p15eu3hv7.bkt.clouddn.com/shu1.png",
            cont: {
                title1: "真才实学的民间高人",
                title2: "真大师·保证每一个真实的好口碑",
                itemList: [ [ "平均从业超十五年", "9项标准，淘汰率高于90%的严苛考核", "预测师100%实名认证，平台身份备案", "79%预测师来自国内各大易学协会", "弘扬正统易学", "仅接受传统易学领域专家入驻", "···" ] ]
            }
        }, {
            url: "http://p15eu3hv7.bkt.clouddn.com/zhe1.png",
            cont: {
                title1: "近百项命理占测服务",
                title2: "命理学 , 涉及生活方方面面",
                itemList: [ [ "洞察和发掘更多的用户需求，", "服务涵盖命盘分析／婚恋感情／事业财富", "取名改名／择日择期／商业决策等近百项服务" ], [ "分手之后，是否还有复合的机会？", "这个项目前景如何，是否值得投资？", "这份工作发展如何，是否值得把握这个机会？", "我和他是否合适，婚后他待我是否如初?", "他是否是一个靠谱的合伙伙伴?", "···" ] ]
            }
        } ],
        scene: "http://pic.imingli.cn/11517749455_.pic_hd.jpg"
    },
    onLoad: function() {
      //获取屏幕宽度，获取自适应单位
   
        var e = this, a = {
            wechat_openid: t.globalData.wechat_openid
        };
      wx.request({
        url: "https://api.xiongmaomingli.com/api/index/user_info",
        data: a,
        method: "POST",
        success: function (t) {
          200 == t.statusCode && 200 == t.data.code && e.setData({
            userInfo: t.data.result
          });
        }
      });
      wx.getSystemInfo({
        success: function (res) {
          e.setData({ rps: res.windowWidth / 375 });
        },
      })
        wx.request({
        url: "https://api.xiongmaomingli.com/api/index/simple",
        data: a,
        method: "POST",
        success: function (t) {
          200 == t.statusCode && 200 == t.data.code && e.setData({
            simple: t.data.result
          });
          var rps = e.data.rps;
          const ctx = wx.createCanvasContext('myCanvas');
          var wxcode = e.data.wx_code;//小图
          var imgPath = e.data.simple.image; //背景图
          ctx.fillRect(0, 0, 350 * rps, 720 * rps);
          ctx.drawImage(imgPath, 0, 0, 350 * rps, 720 * rps);
          ctx.drawImage(wxcode, 250 * rps, 618 * rps, 86 * rps, 96 * rps);
          ctx.draw();
        }
      });
    
     
       
    },
    getSimpleData: function() {
      var e=this;
      var rps = e.data.rps;
      wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 350*rps,
            height:760,
            destWidth: 620,
            destHeight: 1128,
            canvasId: 'myCanvas',
            success: function (res) {
              //调取小程序当中获取图片
              console.log(res.tempFilePath);
              wx.saveImageToPhotosAlbum({
                filePath: res.tempFilePath,
                success(res) {
                  e.setData({
                    tipstate: !1,
                    simpleBtn: !1,
                    // simple: { image: 'http://p15eu3hv7.bkt.clouddn.com/wuxingxiaotupian.png'},
                     
                  });
                }
              })
        },
        fail: function (res) {
          console.log(res);
        }
      })
    },
    getSimple: function() {
        var t = this;
        t.setData({
            tipstate: !0
        }), setTimeout(function() {
            t.getSimpleData();
        }, 1500);
    },
    getFunny: function() {
        var e = this, a = {
            wechat_openid: t.globalData.wechat_openid
        };
        wx.request({
            url: "https://api.xiongmaomingli.com/api/index/interest",
            data: a,
            method: "POST",
            success: function(t) {
                200 == t.statusCode && 200 == t.data.code && e.setData({
                    funny: t.data.result
                });
            }
        });
    },
    tab_choose: function(t) {
        switch (this.setData({
            tab_choose_index: t.currentTarget.dataset.tab_choose_index
        }), this.data.tab_choose_index) {
          case "0":
            "http://p15eu3hv7.bkt.clouddn.com/wuxingxiaotupian.png" == this.data.simple.image ? this.setData({
                tipstate: !1,
                simpleBtn: !0
            }) : this.setData({
                tipstate: !1,
                simpleBtn: !1
            });
            break;

          case "1":
            this.getFunny();
        }
    },
    savePicToLocal: function() {
        if ("http://p15eu3hv7.bkt.clouddn.com/wuxingxiaotupian.png" != this.data.simple.image) {
            var t = this.data.simple.image;
            wx.previewImage({
                urls: t.split(",")
            });
        }
    },
    // showCover: function() {
    //     this.setData({
    //         noticeCover: !0
    //     });
    // },
    hideCover: function() {
        this.setData({
            noticeCover: !1
        });
    },
    previewImage: function(t) {
        var e = [];
        e[0] = this.data.scene, wx.previewImage({
            current: " this.data.scene",
            urls: e
        });
    },
    goWriteIn: function() {
        wx.navigateTo({
            url: "../writeIn/writeIn"
        });
    },
    goNatalChart: function() {
        wx.navigateTo({
            url: "../natalChart/natalChart"
        });
    },
    goFollow: function() {
        wx.navigateTo({
            url: "../follow/follow"
        });
    },
    imageOnLoad: function(t) {
        this.setData({
            url: t.target.dataset.url
        });
    },
    imageOnLoadError: function() {},
    swapperChange: function(t) {
        this.setData({
            textCurrent: t.detail.current
        });
    },
    onShareAppMessage: function(t) {
        return "button" === t.from && console.log(t.target), {
            path: "/pages/index/index",
            success: function(t) {
                console.log(t);
            },
            fail: function(t) {
                console.log(t);
            }
        };
    }
});